# pragma once
# include "../../Foundation/Math/GlimMath.h"

namespace glimmer{

    enum class ConstantBufferDataType
    {
        PerMaterial,
        PerObject,
        PerFrame,    
    };

    struct ConstantBufferDataDirectionLight
    {
        Vec4 m_Direction;
        Vec4 m_Color;
        Vec4 m_Intensity;
    };

    struct ConstantBufferDataSpotLight
    {
        Vec4 m_Direction;
        Vec4 m_Position;
        Vec4 m_Color;
        Vec4 m_Intensity;
    };

    struct ConstantBufferDataPointLight
    {
        Vec4 m_Position;
        Vec4 m_Color;
        Vec4 m_Intensity;
    };

    struct ConstantBufferDataPerFrame
    {
        Matrix4x4 m_ViewMatrix;
        Matrix4x4 m_ProjectionMatrix;
        Matrix4x4 m_ViewToProjectionMatrix;
        ConstantBufferDataDirectionLight m_DirectionLight;
        ConstantBufferDataSpotLight m_SpotLight[4];
        ConstantBufferDataPointLight m_PointLight[4];
        Matrix4x4 m_LightViewProj;
    };

    struct ConstantBufferDataPerObject
	{
		Matrix4x4 m_WorldMatrix;
	};

    class ConstantBuffer{
	
    public:
		explicit ConstantBuffer(ConstantBufferDataType dt, int size);
		virtual ~ConstantBuffer();
		void* GetData()
		{
			return m_Data;
		}

        ConstantBufferDataType GetDataType()
        {
            return m_DataType;
        }

        virtual void Bind() = 0;


	protected:
        ConstantBufferDataType m_DataType;
        int m_Size;
		void* m_Data = nullptr;
	};
}